local skel = fk.CreateSkill {
  name = "emo__shenquan",
}

Fk:loadTranslationTable{
  ["emo__shenquan"] = "神权",
  [":emo__shenquan"] = "连招技（锦囊牌+【杀】），你可以令一名角色失去一点体力并摸X张牌（X为其已损失的体力值）。",

  ["#emo__shenquan-choose"] = "神权：你可以令一名角色失去一点体力并摸X张牌（X为其已损失的体力值）",
}

skel:addEffect(fk.CardUsing, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(skel.name) and
      data.extra_data and data.extra_data.combo_skill and data.extra_data.combo_skill[skel.name]
  end,
  on_cost = function (self, event, target, player, data)
    local tos = player.room:askToChoosePlayers(player, {
      targets = player.room.alive_players, min_num = 1, max_num = 1, skill_name = skel.name, cancelable = true,
      prompt = "#emo__shenquan-choose",
    })
    if #tos == 0 then return false end
    event:setCostData(self, {tos = tos})
    return true
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local to = event:getCostData(self).tos[1] ---@type ServerPlayer
    room:loseHp(to, 1, skel.name)
    if to.dead or not to:isWounded() then return end
    to:drawCards(to:getLostHp(), skel.name)
  end,
})

skel:addEffect(fk.AfterCardUseDeclared, {
  can_refresh = function (self, event, target, player, data)
    return target == player and player:hasSkill(skel.name, true) and data.card.trueName == "slash"
  end,
  on_refresh = function (self, event, target, player, data)
    local room = player.room
    local use_events = room.logic:getEventsByRule(GameEvent.UseCard, 2, function (e)
      return e.data.from == player
    end, 1)
    if #use_events == 2 and use_events[2].data.card.type == Card.TypeTrick then
      data.extra_data = data.extra_data or {}
      data.extra_data.combo_skill = data.extra_data.combo_skill or {}
      data.extra_data.combo_skill[skel.name] = true
    end
  end,
})

return skel
